/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JLevelWindow.java
 *
 * Created on 2010-maj-17, 11:47:46
 */

package foalvleditor.gui;

import foalvleditor.core.impl.LevelModel;

/**
 *
 * @author Mikael
 */
public class JLevelWindow extends javax.swing.JInternalFrame {

    /**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private String name="(Untitled)";

    /** Creates new form JLevelWindow */
    public JLevelWindow() {
        super();
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {

        jLevelPanel1 = new foalvleditor.gui.JLevelPanel();
        jLevelNameTextField = new javax.swing.JTextField();
        jLevelTitleLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
        setIconifiable(true);
        setMaximumSize(new java.awt.Dimension(490, 386));
        setMinimumSize(new java.awt.Dimension(490, 386));
        setName("Form"); // NOI18N

        jLevelPanel1.setName("jLevelPanel1"); // NOI18N

        javax.swing.GroupLayout jLevelPanel1Layout = new javax.swing.GroupLayout(jLevelPanel1);
        jLevelPanel1.setLayout(jLevelPanel1Layout);
        jLevelPanel1Layout.setHorizontalGroup(
            jLevelPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 480, Short.MAX_VALUE)
        );
        jLevelPanel1Layout.setVerticalGroup(
            jLevelPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 320, Short.MAX_VALUE)
        );

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(foalvleditor.core.FoaLvlEditorApp.class).getContext().getResourceMap(JLevelWindow.class);
        jLevelNameTextField.setFont(resourceMap.getFont("jLevelNameTextField.font")); // NOI18N
        jLevelNameTextField.setText(resourceMap.getString("jLevelNameTextField.text")); // NOI18N
        jLevelNameTextField.setName("jLevelNameTextField"); // NOI18N
        jLevelNameTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jLevelNameTextFieldFocusLost(evt);
            }
        });

        jLevelTitleLabel.setText(resourceMap.getString("jLevelTitleLabel.text")); // NOI18N
        jLevelTitleLabel.setName("jLevelTitleLabel"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLevelTitleLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLevelNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 416, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addComponent(jLevelPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLevelPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLevelNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLevelTitleLabel)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jLevelNameTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jLevelNameTextFieldFocusLost
        LevelModel.getInstance().setName(jLevelNameTextField.getText());
    }//GEN-LAST:event_jLevelNameTextFieldFocusLost

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JLevelWindow().setVisible(true);
            }
        });
    }

    public void setLevelName(String name){
        this.name=name;
        jLevelNameTextField.setText(this.name);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField jLevelNameTextField;
    private foalvleditor.gui.JLevelPanel jLevelPanel1;
    private javax.swing.JLabel jLevelTitleLabel;
    // End of variables declaration//GEN-END:variables

}
